Skip to content

Add modebar button for toggling ternary spikelines - #8131

Open
Lexachoc wants to merge 4 commits into
plotly:mainfrom
Lexachoc:feat-ternary-toggle-spikeline-button
Open

Lexachoc wants to merge 4 commits into
plotly:mainfrom
Lexachoc:feat-ternary-toggle-spikeline-button

Conversation

@Lexachoc

@Lexachoc Lexachoc commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #8041.

Similar to the Cartesian spikeline button (toggleSpikelines), this adds a toggleTernarySpikelines button to toggle the ternary spikelines implemented in #8041.

I think this could be very useful.

IMHO, I find the current toggleSpikelines behavior a bit confusing. When I first tried the button, I expected a "toggle" to simply control the visibility of the spikelines, ON or OFF.

That is why toggleTernarySpikelines is designed this way: it hides the current ternary spikelines when turned off and restores their previous visibility states when turned back on.

Reproduce with devtools

Open:

http://localhost:3000/devtools/test_dashboard/index.html

Then run in the console:

Plotly.newPlot(gd, [{
                    type: 'scatterternary',
                    subplot: 'ternary',
                    a: [1],
                    b: [2],
                    c: [3]
                }, {
                    type: 'scatterternary',
                    subplot: 'ternary2',
                    a: [2],
                    b: [3],
                    c: [1]
                }], {
                    ternary: {
                        domain: {x: [0, 0.45]},
                        aaxis: {showspikes: true},
                        baxis: {showspikes: false},
                        caxis: {showspikes: true}
                    },
                    ternary2: {
                        domain: {x: [0.55, 1]},
                        aaxis: {showspikes: false},
                        baxis: {showspikes: true},
                        caxis: {showspikes: false}
                    }
                }, {
                    modeBarButtonsToAdd: ['toggleTernarySpikelines']
                })

Screenshots

image image image

Note

While implementing this, I found a bug #8129, where modebar toggle buttons do not use the correct active icon color on initial render. A fix has been submitted in #8130.

Additional

Docs may also need to be updated to list toggleTernarySpikelines on https://plotly.com/javascript/configuration-options/, https://plotly.com/python/configuration-options/, and possibly other related pages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant